package com.algorithm.heap;

import java.util.List;

import org.junit.Test;

public class TestHeap {

	@Test
	public void testSort() {
		Integer[] data = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
		Heap<Integer> heap = new Heap<Integer>();
		heap.sort(data);

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < data.length; i++) {
			sb.append((data[i]) + ",");
		}
		System.out.println(sb);

		heap.rsort(data);
		sb = new StringBuilder();
		for (int i = 0; i < data.length; i++) {
			sb.append((data[i]) + ",");
		}
		System.out.println(sb);

		data = new Integer[] { 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10 };
		List<Integer> result = heap.maxN(data, 3);
		sb = new StringBuilder();
		for (int i = 0; i < result.size(); i++) {
			sb.append((result.get(i)) + ",");
		}
		System.out.println(sb);

		data = new Integer[] { 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10 };
		result = heap.minN(data, 3);
		sb = new StringBuilder();
		for (int i = 0; i < result.size(); i++) {
			sb.append((result.get(i)) + ",");
		}
		System.out.println(sb);
	}

}
